
package com.stnet.web.enterprice.dynamic;

import java.util.Date;
import java.util.List;

import com.modules.commons.PageAction;
import com.stnet.bases.Constants;
import com.stnet.entity.EnterpriseBulletin;

public class EpBulletinAction extends PageAction
{
    /**
	 * 
	 */
	private List<EnterpriseBulletin> enterpriseBulletinList;
    private EnterpriseBulletin enterpriseBulletin;
    private Long id;
    private String title;
    private String contents;
    private Date initTime;
    private Date endTime;
    private String isTop;
    private String state;
	
  

    public String execute()throws Exception{
        super.pager = epBulletinManagerDao.findEnterpriseBulletin(pageSize, pageNo, "-1");
        enterpriseBulletinList = super.pager.getResultList();
        return Constants.SUCCESS_KEY;
    }

    /**
     * 查看一条公告信息
     * @return
     * @throws Exception
     */
    public String view()throws Exception{
        setEnterpriseBulletin(epBulletinManagerDao.getEnterpriseBulletin(id));
        return Constants.VIEW_KEY;
    }

    /**
     * 编辑一条公告信息
     * @return
     * @throws Exception
     */
    public String edit()throws Exception{
        setEnterpriseBulletin(epBulletinManagerDao.getEnterpriseBulletin(id));
        return Constants.EDIT_KEY;
    }

    /**
     * 修改一条公告信息
     * @return
     * @throws Exception
     */
    public String update()throws Exception {
        initenterpriseBullet();
        epBulletinManagerDao.updateEpBulletin(enterpriseBulletin);
        return Constants.UPDATE_KEY;
    }

    /**
     * 跳转到添加页面
     * @return
     * @throws Exception
     */
    public String add_page()throws Exception{
        return Constants.ADD_PAGE_KEY;
    }

    /**
     * 添加一条公告信息
     * @return
     * @throws Exception
     */
    public String add()throws Exception{
        //initenterpriseBullet();
        epBulletinManagerDao.addEnterpriseBulletin(enterpriseBulletin);
        return Constants.ADD_KEY;
    }

    /**
     * 删除一条公告信息
     * @return
     * @throws Exception
     */
    public String delete() throws Exception{
        epBulletinManagerDao.deleteEpBulletin(id);
        return "delete";
    }

    /**
     * 初始化实体对象
     */
    public void initenterpriseBullet()
    {
        enterpriseBulletin.setTitle(title);
        enterpriseBulletin.setContents(contents);
        enterpriseBulletin.setInitTime(initTime);
        enterpriseBulletin.setEndTime(endTime);
        enterpriseBulletin.setIsTop(isTop);
        enterpriseBulletin.setState(state);
    }

    public String getTitle()
    {
        return title;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public String getContents()
    {
        return contents;
    }

    public void setContents(String contents)
    {
        this.contents = contents;
    }

    public Date getInitTime()
    {
        return initTime;
    }

    public void setInitTime(Date initTime)
    {
        this.initTime = initTime;
    }

    public Date getEndTime()
    {
        return endTime;
    }

    public void setEndTime(Date endTime)
    {
        this.endTime = endTime;
    }

    public void setEnterpriseBulletinList(List<EnterpriseBulletin> enterpriseBulletinList)
    {
        this.enterpriseBulletinList = enterpriseBulletinList;
    }

    public void setEnterpriseBulletin(EnterpriseBulletin enterpriseBulletin)
    {
        this.enterpriseBulletin = enterpriseBulletin;
    }

    public List<EnterpriseBulletin> getEnterpriseBulletinList()
    {
        return enterpriseBulletinList;
    }

    public EnterpriseBulletin getEnterpriseBulletin()
    {
        return enterpriseBulletin;
    }

    public String getIsTop()
    {
        return isTop;
    }

    public void setIsTop(String isTop)
    {
        this.isTop = isTop;
    }

    public String getState()
    {
        return state;
    }

    public void setState(String state)
    {
        this.state = state;
    }

    public void setId(Long id)
    {
        this.id = id;
    }
}